package hoyo.zqy.basic.service.impl;

import hoyo.zqy.basic.exception.BusinessException;
import hoyo.zqy.basic.service.IBaiduAiAuditService;
import hoyo.zqy.basic.util.BaiduAuditUtils;
import lombok.var;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class BaiduAiAuditServiceImpl implements IBaiduAiAuditService {


    /**
     * 宠物名称审核
     * @param text
     * @return
     */
    @Override
    public Boolean textAudit(String text) {
        if (!BaiduAuditUtils.TextCensor(text)){
            return false;
        }else {
            return true;
        }
    }

    /**
     * 宠物图片审核
     * @param resources 资源，多张图片通过会用“，”分隔
     * @return
     */
    @Override
    public Boolean imageAudit(String resources) {
        //审核图片
       //判断是否有图片
        if(!StringUtils.isEmpty(resources)){
            //用一个数组进行接收，进行分割
            String[] arr = resources.split(",");
            //获取全部图片
            for(int i = 0; i<arr.length; i++){
                //进行审核
                if (!BaiduAuditUtils.ImgCensor("http://123.207.27.208"+arr[i])){
                    return false;
                }
            }
        }else {
            return true;
        }
        return true;
    }
}
